<input type="hidden" name="id" th:value="${modelThingParam.id}" />
<table class="editTable">
	<tr>
		<td style="text-align:right">实物</td>
		<td><input type="text" id="thingId" name="thingId" th:value="${modelThingParam.thingId}"
			data-toggle="topjui-combobox"
			data-options="width:300,panelHeight:'auto',hasDownArrow:true,readonly:true,
				valueField:'id',textField:'name',url:'/model/thing/combo'"></td>
	</tr>
	<tr>
		<td style="text-align:right">名称</td>
		<td><input type="text" id="paramName" name="name" th:value="${modelThingParam.name}"
			data-toggle="topjui-textbox"
			data-options="required:true,width:300,validType:'length[0,255]',onChange:textboxOnChange"></td>
	</tr>
	<tr>
		<td style="text-align:right">参数键</td>
		<td><input type="text" name="paramKey" th:value="${modelThingParam.paramKey}"
			data-toggle="topjui-textbox"
			data-options="width:300,validType:'length[0,255]'"></td>
	</tr>
	<tr>
		<td style="text-align:right">参数值</td>
		<td><input type="text" name="paramValue" th:value="${modelThingParam.paramValue}"
			data-toggle="topjui-textbox"
			data-options="width:300,validType:'length[0,255]'"></td>
	</tr>
	<tr>
		<td style="text-align:right">备注</td>
		<td><input type="text" name="remark" th:value="${modelThingParam.remark}"
			data-toggle="topjui-textarea"
			data-options="width:300,validType:'length[0,255]'"></td>
	</tr>
</table>

<script type="text/javascript">
	
	var initName = "";
	var params = [];

	$(function() {
		initName = $('#paramName').val();
		var thingId = $('#thingId').val();
		if (thingId != null && thingId != undefined && thingId != "") {
			$.ajax({
				type : "get",
				url : "/model/neo4j/getAllParamNames?label=thing&nodeUuid=" + thingId,
				contentType : "application/json; charset=utf-8",
				success : function(result) {
					if (result.code == 200) {
						// 判断接口返回数据中是否存在params
						if (result.data != null && result.data.length > 0) {
							params = result.data;
						}
					}
				}
			});
		}
	});

	function textboxOnChange(newValue, oldValue) {
		// 判断接口返回数据中是否存在params
		if (params != null && params.length > 0) {
			if (newValue != null && newValue != undefined && newValue != "" && 
					newValue != initName && params.indexOf(newValue) > -1) {
				$("#paramName").iTextbox('clear');
				$.iMessager.alert('警告', '关联参数重复，请重试！');
			}
		}
	}
</script>